﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;

namespace FinPlusCommon
{
    public interface IFunctions : IDictionary<int, IFunction>, ICollection<KeyValuePair<int, IFunction>>, IEnumerable<KeyValuePair<int, IFunction>>
    {
        string[] DisplayFields { get; set; }
        string[] DisplayOrder { get; set; }
        string Id { get;}
        EventHandler<ItemEventArgs> FuncUpdate { get; set; }

        IFunctions Clone();

        void Refresh();

        void Add(IFunctions funcs, bool NextId = true, bool setId = true);

        IFunction Add(IFunction func, bool NextId = true, bool setId = true);

        void Get<T>(string name, T defaultValue, PropertyChangedEventHandler changeEventHander = null);

        void Set<T>(string name, string value, T defaultValue);

        void Update(IFunction func, ChangeType changeType);

        void Remove(string expression);

        bool TryRemove(int functionId, out IFunction func);

        IFunction Get(string id);

        IFunction First(string expression);

        IDictionary<string, IFunction> Where(string expression, string key = "Id");

        XmlDocument ToXmlDoc(string nodes = "");

        string ToString();

        string ToString(string node = "");

        string ToString(FieldType fieldType);

        IFunction[] ToArray(string name, string match);

        IList<IFunction> ToList(string name, string match, bool isValMatch = true);

        IList<IFunction> ToList(string name, string match, char delimitor);

        IList<string> ToList(string name);

        IDictionary<string, string> ToDictionary(string key, string value);

        int NextKey();
    }
}
